//
//  KKCommentCell.m
//  DoMi
//
//  Created by 康凯 on 2016/11/10.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKCommentCell.h"
#import "KKStudyHttp.h"
#import "KKPersonalHomeVC.h"

@interface KKCommentCell()
@property(nonatomic,copy)NSString *userId;
@end

@implementation KKCommentCell
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//    "commentid": "1",
//    "uid": "1",
//    "commentcontent": "123456",
//    "commenttime": "2016-10-26 15:17:27",
//    "reply": 100,
//    "commentlike": 200
-(void)initData:(KKCommentM *)comment{
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(likeClick)];
    [self.likeView addGestureRecognizer:tap];
    UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushAvatar)];
    [self.avater addGestureRecognizer:tap1];
    self.commentInfo=comment;
    self.replyView.hidden=NO;
    self.likeView.hidden=NO;
    self.content.text=comment.commentcontent;
    self.replyCount.text=comment.reply;
    self.zanCount.text=comment.commentlike;
    self.time.text=comment.commenttime;
    [self.avater sd_setImageWithURL:[NSURL URLWithString:self.commentInfo.avatar] placeholderImage:[UIImage imageNamed:@"default_avater"]];
    self.name.text=self.commentInfo.nickname;
    self.tag1.text=self.commentInfo.job;
    self.tag2.text=self.commentInfo.industry;
    self.userId=comment.uid;
}
-(void)initReplyData:(KKCommentM *)comment{
    self.replyView.hidden=YES;
    self.likeView.hidden=YES;
    self.content.text=comment.replycontent;
    self.replyCount.text=comment.reply;
    self.zanCount.text=comment.commentlike;
    self.time.text=comment.replytime;
    [self.avater sd_setImageWithURL:[NSURL URLWithString:comment.avatar] placeholderImage:[UIImage imageNamed:@"default_avater"]];
    self.name.text=comment.nickname;
    self.tag1.text=comment.job;
    self.tag2.text=comment.industry;
    UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushAvatar)];
    [self.avater addGestureRecognizer:tap1];
    self.userId=comment.uid;
}
//点赞
-(void)likeClick{
    [KKStudyHttp addCommentLike:self.commentInfo.commentid success:^(id data) {
        self.commentInfo.commentlike=data;
        self.zanCount.text=data;
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 按钮--头像
-(void)pushAvatar{
    UIViewController *controller=[KKAppUtils getCurrentVisiableVC:self];
    KKPersonalHomeVC *personHome=[[KKPersonalHomeVC alloc] init];
    personHome.expertId=self.userId;
    [controller.navigationController pushViewController:personHome animated:YES];
}
@end
